package muview;

import java.io.File;
import java.util.List;

import com.cloudgarden.resource.SWTResourceManager;

import mumethod.AccessStudents;
import mumethod.Base64String;
import mumethod.LibFunction;
import mumethod.CountTableRow;
import mumethod.ExportFunction;
import mumethod.ImportFunction;
import mumethod.ViewFunction;
import muobject.Student;
import muobject.SystemProperty;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.springframework.context.ApplicationContext;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class TeacherStudentInput extends Composite {

	{
		// Register as a resource user - SWTResourceManager will
		// handle the obtaining and disposing of resources
		SWTResourceManager.registerResourceUser(this);
	}

	private ApplicationContext springConnector;
	private AccessStudents getStudends;
	private String templatePath;
	private String year;
	private String sno;
	private String grade;
	private String sclass;
	private List<String> grades;
	private List<String> sclasses;
	private boolean editFlat;
	private Button but_gcselect;
	private Combo cmb_class;
	private Label lab_class;
	private Combo cmb_grade;
	private Label lab_grade;
	private Button but_exceltampate;
	private Button but_studentinput;
	private Button but_studentexport;
	private Label lab_studenttitle;
	private Button but_addstudent;
	private Button but_deleteallstudent;
	private Button but_deletestudent;
	private Button but_studentsave;
	private Color selectColor;
	private Composite pageStudentComposite;
	private Table table;
	private String currentYear;
	private int selectColumn;
	private ImportFunction importFunction;
	private ExportFunction exportFunction;

	public void Init(SystemProperty systemProperty) {
		springConnector = systemProperty.getSpringConnector();
		getStudends = (AccessStudents) springConnector
				.getBean("AccessStudentsService");
		year = systemProperty.getYear();
		sno = systemProperty.getSno();
		grade = systemProperty.getGrade();
		sclass = systemProperty.getSclass();
		editFlat = systemProperty.getYear().substring(0, 4)
				.equals(systemProperty.getCurrentYear());
		currentYear = systemProperty.getCurrentYear();
		templatePath = systemProperty.getTemplatePath();
		selectColor = new Color(this.getDisplay(),135,206,250);
		importFunction = new ImportFunction();
		exportFunction = new ExportFunction();
	}

	public TeacherStudentInput(Composite c, final Shell shell, final SystemProperty systemProperty) {
		super(c, SWT.BORDER);
		Init(systemProperty);
		FillLayout CompositeFormLayout = new FillLayout();
		this.setLayout(CompositeFormLayout);
		this.setSize(990, 520);
		{
			Composite composite = new Composite(this, SWT.NONE);
			GridLayout compositeLayout = new GridLayout();
			compositeLayout.makeColumnsEqualWidth = true;
			compositeLayout.numColumns = 8;
			composite.setLayout(compositeLayout);
			{
				lab_studenttitle = new Label(composite, SWT.NONE);
				GridData lab_studenttitleLData = new GridData(
						GridData.VERTICAL_ALIGN_END);
				lab_studenttitleLData.horizontalSpan = 5;
				lab_studenttitle.setLayoutData(lab_studenttitleLData);
				lab_studenttitle
						.setText("\u66f4\u65b0 / \u8655\u7406\u5b78\u751f\u66f4\u65b0\u540d\u55ae");
				lab_studenttitle.setFont(SWTResourceManager.getFont("Tahoma",
						20, 1, false, false));
			}
			{
				but_exceltampate = new Button(composite, SWT.PUSH | SWT.CENTER);
				GridData but_exceltampateLData = new GridData(
						GridData.VERTICAL_ALIGN_END);
				but_exceltampateLData.horizontalSpan = 1;
				but_exceltampate.setLayoutData(but_exceltampateLData);
				but_exceltampate.setText("\u8cc7\u6599\u683c\u5f0f");
				but_exceltampate.setFont(SWTResourceManager.getFont("Tahoma",
						16, 1, false, false));
				but_exceltampate.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent e) {
						FileDialog fileDialog = new FileDialog(shell, SWT.SAVE);
						fileDialog.setText("Save");
						fileDialog.setFilterPath("C:/");
						fileDialog.setFileName("Student.xls");
				        String[] filterExt = { "*.xls" };
				        fileDialog.setFilterExtensions(filterExt);
				        String distinationPath = fileDialog.open();
				        if(distinationPath != null){
				        	File file = new File(distinationPath);
					        if (file.exists()) {
					        	if (DialogQuestion.open(shell, "已存在。\n要覆蓋嗎？","確定覆蓋??", SWT.ICON_QUESTION)) {
					        		 if(exportFunction.ExportStudentTemplateExcel(systemProperty.getTemplatePath(), distinationPath)){
								        	DialogMessage.open(shell, "儲存成功","儲存成功", SWT.ICON_INFORMATION);
								        }
					        	}
					        }else if(distinationPath != null) {
					        	 if(exportFunction.ExportStudentTemplateExcel(systemProperty.getTemplatePath(), distinationPath)){
							        	DialogMessage.open(shell, "儲存成功","儲存成功", SWT.ICON_INFORMATION);
							        }
					        }
				        }
					}
				});
			}
			{
				but_studentinput = new Button(composite, SWT.PUSH | SWT.CENTER);
				GridData but_studentinputLData = new GridData(
						GridData.VERTICAL_ALIGN_END);
				but_studentinputLData.horizontalSpan = 1;
				but_studentinput.setLayoutData(but_studentinputLData);
				but_studentinput.setText("\u8cc7\u6599\u532f\u5165");
				but_studentinput.setFont(SWTResourceManager.getFont("Tahoma",
						16, 1, false, false));
				but_studentinput.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent e) {
						DialogExcelPath dialogExcelPathnew = new DialogExcelPath(shell);
						String excelPath = dialogExcelPathnew.open();
						if(!excelPath.equals("")){
						table.removeAll();
						importFunction.ImportStudentExcel(excelPath, table);
						}
					}
				});
			}
			{
				but_studentexport = new Button(composite, SWT.PUSH | SWT.CENTER);
				GridData but_studentinputLData = new GridData(
						GridData.VERTICAL_ALIGN_END);
				but_studentinputLData.horizontalSpan = 1;
				but_studentexport.setLayoutData(but_studentinputLData);
				but_studentexport.setText("\u8cc7\u6599\u532f\u51fa");
				but_studentexport.setFont(SWTResourceManager.getFont("Tahoma",
						16, 1, false, false));
				but_studentexport.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent e) {
						FileDialog fileDialog = new FileDialog(shell, SWT.SAVE);
						fileDialog.setText("Save");
						fileDialog.setFilterPath("C:/");
						fileDialog.setFileName("學生資料.xls");
				        String[] filterExt = { "*.xls" };
				        fileDialog.setFilterExtensions(filterExt);
				        String distinationPath = fileDialog.open();
				        if(distinationPath != null){
				        	 File file = new File(distinationPath);
						        if (file.exists()) {
						        	if (DialogQuestion.open(shell, "已存在。\n要覆蓋嗎？","確定覆蓋??", SWT.ICON_QUESTION)) {
						        		exportFunction.ExportTableExcel(table, distinationPath, "學生資料");
						        	}
						        }else if(distinationPath != null) {
						        	exportFunction.ExportTableExcel(table, distinationPath, "學生資料");
						        }
				        }
					}
				});
			}
			// ---------------------------------------------------------------------------------------------------------------
			{
				lab_grade = new Label(composite, SWT.NONE);
				GridData lab_gradeLData = new GridData();
				lab_gradeLData.horizontalSpan = 1;
				lab_gradeLData.verticalAlignment = SWT.CENTER;
				lab_grade.setLayoutData(lab_gradeLData);
				lab_grade.setText("\u5b78\u751f\u5e74\u7d1a :");
				lab_grade.setFont(SWTResourceManager.getFont("Tahoma", 12, 1,
						false, false));
			}
			{
				grades = getStudends.getAllGrade(sno, year, sclass);
				grades.add("All");
				GridData cmb_gradeLData = new GridData();
				cmb_gradeLData.widthHint = 95;
				cmb_gradeLData.horizontalSpan = 1;
				cmb_gradeLData.horizontalIndent = -35;
				cmb_gradeLData.verticalAlignment = SWT.CENTER;
				cmb_grade = new Combo(composite, SWT.NONE);
				cmb_grade.setLayoutData(cmb_gradeLData);
				for (String str : grades) {
					cmb_grade.add(str);
				}
				cmb_grade.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent e) {
						grade = cmb_grade.getText().equals("All") ? "%"
								: cmb_grade.getText();
						sclass = "%";
						sclasses = getStudends.getAllSclass(sno, year, grade);
						sclasses.add("All");
						cmb_class.removeAll();
						for (String str : sclasses) {
							cmb_class.add(str);
						}
						table.removeAll();
						tableGetData();
					}
				});
			}
			{
				lab_class = new Label(composite, SWT.NONE);
				GridData lab_classLData = new GridData();
				lab_classLData.horizontalSpan = 1;
				lab_classLData.horizontalAlignment = SWT.CENTER;
				lab_class.setLayoutData(lab_classLData);
				lab_class.setText("\u5b78\u751f\u73ed\u5225 :");
				lab_class.setFont(SWTResourceManager.getFont("Tahoma", 12, 1,
						false, false));
			}
			{
				sclasses = getStudends.getAllSclass(sno, year, grade);
				sclasses.add("All");
				GridData cmb_classLData = new GridData();
				cmb_classLData.widthHint = 95;
				cmb_classLData.horizontalSpan = 1;
				cmb_classLData.horizontalIndent = -15;
				cmb_classLData.verticalAlignment = SWT.CENTER;
				cmb_class = new Combo(composite, SWT.NONE);
				cmb_class.setLayoutData(cmb_classLData);
				for (String str : sclasses) {
					cmb_class.add(str);
				}
				cmb_class.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent e) {
						sclass = cmb_class.getText().equals("All") ? "%"
								: cmb_class.getText();
						table.removeAll();
						tableGetData();
					}
				});
			}
			
			// ---------------------------------------------------------------------------------------------------------------
			{
				GridData getStudentTableLData = new GridData();
				getStudentTableLData.horizontalSpan = 8;
				getStudentTableLData.horizontalAlignment = GridData.CENTER;
				getStudentTableLData.widthHint = 950;
				getStudentTableLData.heightHint = 400;
				pageStudentComposite = new Composite(composite, SWT.NONE);
				pageStudentComposite.setLayout(new FillLayout());
				pageStudentComposite.setLayoutData(getStudentTableLData);
				{
					table = new Table(pageStudentComposite, SWT.BORDER
							| SWT.V_SCROLL | SWT.H_SCROLL);
					{
						String[] titles = { "入學編號", "級別", "班別", "班號", "中文姓名",
								"英文姓名", "姓別", "出生日期" };

						for (int loopIndex = 0; loopIndex < titles.length; loopIndex++) {
							TableColumn column = new TableColumn(table,
									SWT.NULL);
							column.setText(titles[loopIndex]);
							column.setWidth(110);
						}
						TableColumn column = new TableColumn(table, SWT.NULL);
						column.setWidth(0);
						column.setResizable(false);
					}
					GetStudentTable();
				}
			}
			// ---------------------------------------------------------------------------------------------------------------
			{
				Composite bottomComposite = new Composite(composite, SWT.NONE);
				GridData bottomCompositeLData = new GridData();
				bottomCompositeLData.horizontalSpan = 8;
				bottomCompositeLData.widthHint = 800;
				bottomComposite.setLayoutData(bottomCompositeLData);
				bottomComposite.setLayout(new RowLayout());
				{
					but_addstudent = new Button(bottomComposite, SWT.PUSH
							| SWT.CENTER);
					but_addstudent
							.setText("\u52a0\u5165\u5b78\u751f\u8cc7\u6599");
					but_addstudent.setFont(SWTResourceManager.getFont("Tahoma",
							16, 1, false, false));
					but_addstudent.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent e) {
							TableItem item = new TableItem(table, SWT.NULL);
							item.setText(1, grade);
							item.setText(2, sclass);
							item.setText(8, "0");
							item.setText(7, "1990-01-01");
						}
					});
				}
				{
					but_deleteallstudent = new Button(bottomComposite, SWT.PUSH
							| SWT.CENTER);
					but_deleteallstudent.setText("\u522a\u9664\u6b64\u9801\u8cc7\u6599");
					but_deleteallstudent.setFont(SWTResourceManager.getFont(
							"Tahoma", 16, 1, false, false));
					but_deleteallstudent
							.addSelectionListener(new SelectionAdapter() {
								public void widgetSelected(SelectionEvent e) {
									try {
										if(DialogQuestion.open(shell, "確定刪除??","確定刪除??", SWT.ICON_QUESTION)){
											getStudends.deleteStudentFromTable(table,systemProperty.getYear(),systemProperty.getSno());
											reflushControl();
											DialogMessage.open(shell, "刪除成功","刪除成功", SWT.ICON_INFORMATION);
										}
									} catch (Exception esave) {
										DialogMessage.open(shell, "刪除失敗",
												"刪除失敗", SWT.ICON_WARNING);
									}
								}
							});
				}
				{
					but_deletestudent = new Button(bottomComposite, SWT.PUSH | SWT.CENTER);
					but_deletestudent.setText("\u522a\u9664\u6240\u9078\u8cc7\u6599");
					but_deletestudent.setFont(SWTResourceManager.getFont(
							"Tahoma", 16, 1, false, false));
					but_deletestudent
					.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent e) {
							try {
								String stno = table.getItem(selectColumn).getText(0);
								if(getStudends.existStudent(stno, sno, year)){
									if(DialogQuestion.open(shell, "是否刪除資料庫資料??","是否刪除資料庫資料??", SWT.ICON_QUESTION)){
										if(getStudends.deleteStudentByStno(stno)){
											reflushControl();
											DialogMessage.open(shell, "刪除成功","刪除成功", SWT.ICON_INFORMATION);
										}else{
											DialogMessage.open(shell, "刪除失敗","刪除失敗", SWT.ICON_WARNING);
										}
									}else{
										table.remove(selectColumn);
									}
								}
								selectColumn = -1;
							} catch (Exception esave) {
							}
						}
					});
				}
				{
					but_studentsave = new Button(bottomComposite, SWT.PUSH | SWT.CENTER);
					but_studentsave.setText("\u5132\u5b58\u8cc7\u6599");
					but_studentsave.setFont(SWTResourceManager.getFont(
							"Tahoma", 16, 1, false, false));
					but_studentsave
					.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent e) {
							try {
								if(getStudends.checkStudentTable(table)){
									if(DialogQuestion.open(shell, "確定儲存資料??","確定儲存資料??", SWT.ICON_QUESTION)){
										if(getStudends.setStudentFromTable(table,systemProperty.getYear(),systemProperty.getSno())){
											DialogMessage.open(shell, "儲存成功", "儲存成功", SWT.ICON_INFORMATION);
											reflushControl();
										}
									}
								}else{
									DialogMessage.open(shell, "資料格式錯誤","資料格式錯誤", SWT.ICON_WARNING);
								}
							} catch (Exception esave) {
								DialogMessage.open(shell, "儲存失敗","儲存失敗", SWT.ICON_WARNING);
							}
						}
					});
				}
			}

		}
	}

	private void GetStudentTable() {
		table.setHeaderVisible(true);
		table.setLinesVisible(true);
		table.setFont(SWTResourceManager.getFont("Tahoma", 9, 0, false, false));
		{

			tableGetData();
		    
			table.addListener(SWT.MeasureItem, new Listener() {
				   public void handleEvent(Event event) {
				      event.height = 15;
				   }
				});
			
			if (editFlat) {
				final TableEditor editor = new TableEditor(table);
				editor.horizontalAlignment = SWT.LEFT;
				editor.grabHorizontal = true;
				table.addMouseListener(new MouseAdapter() {
					public void mouseDown(MouseEvent event) {
						Rectangle clientArea = table.getClientArea();
						Point pt = new Point(event.x, event.y);
						int index = table.getTopIndex();
						while (index < table.getItemCount()) {
							boolean visible = false;
							final TableItem item = table.getItem(index);
							final Combo sexCombo = new Combo(table, SWT.READ_ONLY);
							sexCombo.add("M");
							sexCombo.add("F");
							final int indexNow = index;
							for (int i = 0; i < table.getColumnCount(); i++) {
								Rectangle rect = item.getBounds(i);
								if (rect.contains(pt)) {
									final Text text = new Text(table, SWT.NONE);
									final CountTableRow countTableRow = new ViewFunction();
									countTableRow.setTableRowCount(0);
									Listener textListener = new Listener() {
										public void handleEvent(final Event e) {
											switch (e.type) {
											case SWT.FocusOut:
												table.getItem(indexNow + countTableRow.getTableRowCount())
												     .setText(editor.getColumn(),text.getText());
												table.getItem(indexNow + countTableRow.getTableRowCount())
												     .setBackground(new Color(table.getDisplay(),255,255,255));
												text.dispose();
												break;
											case SWT.Traverse:
												int blockRow = 0;
												switch (e.detail) {
												case SWT.TRAVERSE_RETURN:
													if (indexNow+ countTableRow.getTableRowCount()+ 1 >= table.getItemCount())
														break;
													for (int i = countTableRow.getTableRowCount(); i <= table.getItemCount(); i++) {
														countTableRow.addTableColumnCount();
														blockRow += 1;
														table.getItem(indexNow + countTableRow.getTableRowCount() - blockRow)
																.setText(editor.getColumn(), text.getText());
														if (countTableRow.getTableRowCount() >= table.getColumnCount())
															break;
														
														editor.setEditor(text,table.getItem(indexNow+ countTableRow.getTableRowCount()),0);
														text.setText(table.getItem(indexNow + countTableRow.getTableRowCount()).getText(0));
														text.selectAll();
														text.setFocus();
														table.getItem(indexNow + countTableRow.getTableRowCount()- blockRow)
																	.setBackground(new Color(table.getDisplay(),255,255,255));
														table.getItem(indexNow + countTableRow.getTableRowCount())
																	.setBackground(selectColor);
														selectColumn = indexNow + countTableRow.getTableRowCount();
														break;
													}
													break;
												case SWT.TRAVERSE_ESCAPE:
													text.dispose();
													e.doit = false;
													selectColumn = -1;
													break;
												case SWT.TRAVERSE_TAB_NEXT:
													if (editor.getColumn() + 2 == table.getColumnCount()) {
														if (indexNow + countTableRow.getTableRowCount() + 1 >= table.getItemCount())
															break;
														for (int i = countTableRow.getTableRowCount(); i <= table.getItemCount(); i++) {
															countTableRow.addTableColumnCount();
															blockRow += 1;
															table.getItem(indexNow + countTableRow.getTableRowCount() - blockRow)
																	.setText(editor.getColumn(), text.getText());
															editor.setEditor(text, table.getItem(indexNow + countTableRow.getTableRowCount()),0);
															text.setText(table.getItem(indexNow + countTableRow.getTableRowCount())
																		.getText(0));
															text.selectAll();
															text.setFocus();
															table.getItem(indexNow + countTableRow.getTableRowCount()- blockRow)
																		.setBackground(new Color(table.getDisplay(),255,255,255));
															table.getItem(indexNow + countTableRow.getTableRowCount())
																		.setBackground(selectColor);
															selectColumn = indexNow + countTableRow.getTableRowCount();
															break;
														}
														e.doit = false;
														e.detail = SWT.TRAVERSE_NONE;
													} else {
														table.getItem(indexNow + countTableRow.getTableRowCount())
																.setText(editor.getColumn(),text.getText());
														editor.setEditor(text,table.getItem(indexNow + countTableRow.getTableRowCount()),editor.getColumn() + 1);
														text.setText(table.getItem(indexNow + countTableRow.getTableRowCount())
																.getText(editor.getColumn()));
														text.selectAll();
														text.setFocus();
														selectColumn = indexNow + countTableRow.getTableRowCount();
														e.doit = false;
														e.detail = SWT.TRAVERSE_NONE;
													}
													break;
												}
												break;
											}
										}
									};
									Listener comboListener = new Listener() {
										public void handleEvent(final Event e) {
											switch (e.type) {
											case SWT.FocusOut:
												item.setBackground(new Color(table.getDisplay(),255,255,255));
												sexCombo.dispose();
												break;
											case SWT.Selection:
												item.setBackground(new Color(table.getDisplay(),255,255,255));
												item.setText(6, sexCombo.getText());
												sexCombo.dispose();
									            break;
											}
										}
									};
										
											
									text.addListener(SWT.FocusOut, textListener);
									text.addListener(SWT.Traverse, textListener);
									sexCombo.addListener(SWT.FocusOut, comboListener);
									sexCombo.addListener(SWT.Selection, comboListener);
									
									if (i == 6){
										item.setBackground(selectColor);
										sexCombo.select(sexCombo.indexOf(item.getText(i)));
								        editor.minimumWidth = sexCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
								        sexCombo.setFocus();
								        editor.setEditor(sexCombo, item, i);
								    }else{
								    	item.setBackground(selectColor);
								    	editor.setEditor(text, item, i);
								    	text.setText(item.getText(i));
								    	text.selectAll();
								    	text.setFocus();
								    }
									selectColumn = indexNow + countTableRow.getTableRowCount();
									return;
								}
								if (!visible && rect.intersects(clientArea)) {
									visible = true;
									selectColumn = -1;
								}
							}
							if (!visible)
								return;
							index++;
						}
					}
				});
			}

		}
	}
	
	public void tableGetData(){
		List<Student> students = getStudends.getSpicalStudents(sno,
				year, grade, sclass);

		for (Student student : students) {
			TableItem item = new TableItem(table, SWT.NULL);
			item.setText("");
			item.setText(0, student.getStno());
			item.setText(1, student.getGrade());
			item.setText(2, student.getSclass());
			item.setText(3, String.valueOf(student.getClassno()));
			item.setText(4, student.getCname());
			item.setText(5, student.getEname());
			item.setText(6, student.getSex());
			item.setText(7, String.valueOf(student.getBirthday()));
			item.setText(8, String.valueOf(student.getStid()));
		}
	}
	
	public void reflushControl(){
		table.removeAll();
		tableGetData();
		grades = getStudends.getAllGrade(sno, year,
				sclass);
		grades.add("All");
		sclasses = getStudends.getAllSclass(sno, 
				year, grade);
		sclasses.add("All");
		cmb_grade.removeAll();
		for (String str : grades) {
			cmb_grade.add(str);
		}
		cmb_class.removeAll();
		for (String str : sclasses) {
			cmb_class.add(str);
		}
	}
}
